<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="贾文清">
    <title></title>
    <style>
        main {
            width: 500px;
            /* height: 200px; */
            border: 1px solid red;
            margin: 0 auto;
        }

        .box {
            width: 500px;
            height: 40px;
            background-color: black;
            color: white;
            display: flex;
        }

        .box section {
            width: 100px;
            height: 40px;
            line-height: 40px;
            text-align: center;
        }

        #content-box {
            display: block;
        }

        .content {
            width: 100px;
            margin: 0 auto;
             display: none; 
        }
         .content p{
             text-align: center;
         }

        .first {
            background-color: lightgray;
        }
    </style>
</head>

<body>
    <main>
        <div class="box">
            <section class="first">选项一</section>
            <section>选项二</section>
            <section>选项三</section>
        </div>
        <div>
            <div class="content " id="content-box">
                <p>内容一</p>
                <p>内容一</p>
            </div>
            <div class="content">
                <p>内容二</p>
                <p>内容二</p>
                <p>内容二</p>
                <p>内容二</p>
            </div>
            <div class="content">
                <p>内容三</p>
                <p>内容三</p>
                <p>内容三</p>
            </div>
        </div>
    </main>
    <script src="./jquery.js"></script>
</body>

</html>
<script>
    // each()为每一个匹配到的元素执行一个函数
    $('section').each(function (index) {
        $('section').eq(index).mouseover(function () {
            $('section').eq(index).css('background-color', 'lightgray').siblings().css('background-color', 'black');
            $('.content').eq(index).css('display', 'block').siblings().css('display', 'none');
        })
    });

</script>